package com.joker.demo.core.domain.enums;


/**
 * 任务调度类型
 *
 * @author : feixiang.li
 * @since : 2025-07-23 21:11
 */
public enum JobSchedulingTypeEnum {


    /**
     * cron表达式
     * 手动调度
     */
    CRON(1, "CRON"),
    /**
     * 固定频率
     */
    FIX_RATE(2, "FIX_RATE"),
    /**
     * 固定延迟
     */
    FIX_DELAY(3, "FIX_DELAY"),

    /*
     * 手动调度
     */
    MANUAL(4, "MANUAL"),
    ;
    private final Integer code;
    private final String desc;

    JobSchedulingTypeEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static JobSchedulingTypeEnum getByCode(Integer code) {
        for (JobSchedulingTypeEnum value : JobSchedulingTypeEnum.values()) {
            if (value.code.equals(code)) {
                return value;
            }
        }
        return null;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }


    public static JobSchedulingTypeEnum getByDesc(String desc) {
        for (JobSchedulingTypeEnum value : JobSchedulingTypeEnum.values()) {
            if (value.desc.equals(desc)) {
                return value;
            }
        }
        return null;
    }
}
